export const getAuth = () => {
    const token = localStorage.getItem('token');
    return token ? token : null;
};

export const setAuth = (token) => {
    localStorage.setItem('token', token);
};

export const setUserInfo = (user) => {
    localStorage.setItem('user', JSON.stringify(user));
};

export const getUserInfo = () => {
    const user = localStorage.getItem('user');
    return user ? JSON.parse(user) : null;
}

export const logout = () => {
    localStorage.removeItem('token');
    localStorage.removeItem('user');
    window.location.reload(); // 强制刷新清除状态
};


